package cn.zktr.Personnel.model.service.zhouyongcong.end;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.zktr.Personnel.model.pojos.PerPmsFun;
import cn.zktr.Personnel.model.pojos.PerPmsFuns;
import cn.zktr.Personnel.model.pojos.PerPmsPes;
import cn.zktr.Personnel.model.pojos.PerPmsYG;
import cn.zktr.Personnel.model.pojos.PerPmsYQ;
import cn.zktr.Personnel.model.service.zhouyongcong.findService;
//导航栏Service
@Service
@Transactional(rollbackFor=Exception.class)
public class hopapapeService {
	@Autowired
	private findService fs;
	//一级标签
	public List<PerPmsPes> tail_1(int empid){
		List<PerPmsYQ> list = fs.findEmpid(empid).getPerPmsYQs();
		List<PerPmsPes> list_1 = new ArrayList<>();
		for(PerPmsYQ ppyq : list) {
			if(ppyq.getYqwht().equals("true")) {
				PerPmsPes ppp = ppyq.getPerPmsPe();
				PerPmsPes ppp1 = new PerPmsPes();
				ppp1.setPesgad(ppp.getPesgad());
				ppp1.setPesid(ppp.getPesid());
				ppp1.setPesname(ppp.getPesname());
				ppp1.setPesurl(ppp.getPesurl());
				list_1.add(ppp1);
			}
		}
		return list_1;
	}
	//二级标签
	public List<PerPmsFun> tail_2(int empid,String tatext){
		List<PerPmsYG> list = fs.findEmpid(empid).getPerPmsYGs();
		List<PerPmsFun> list_1 = new ArrayList<>();
		for(PerPmsYG ppyg : list) {
			if(ppyg.getPerPmsFun().getPerPmsPe().getPesname().equals(tatext)) {
				if(ppyg.getPerPmsFun().getFungad().equals("3")) {
					if(ppyg.getYgwht().equals("true")) {
						PerPmsFun ppf = ppyg.getPerPmsFun();
						PerPmsFun ppf1 = new PerPmsFun();
						ppf1.setFungad(ppf.getFungad());
						ppf1.setFunid(ppf.getFunid());
						ppf1.setFunname(ppf.getFunname());
						ppf1.setFunurl(ppf.getFunurl());
						List<PerPmsFuns> list_2 = new ArrayList<>();
						for(PerPmsFuns ppfs : ppf.getPerPmsFuns()) {
							if(ppfs.getFunsgad().equals("3")) {
								PerPmsFuns ppfs2 = new PerPmsFuns();
								ppfs2.setFunsgad(ppfs.getFunsgad());
								ppfs2.setFunsid(ppfs.getFunsid());
								ppfs2.setFunsname(ppfs.getFunsname());
								ppfs2.setFunsurl(ppfs.getFunsurl());
								list_2.add(ppfs2);
							}
						}
						ppf1.setPerPmsFuns(list_2);
						list_1.add(ppf1);
					}
				}
			}
		}
		return list_1;
	}
	public List<PerPmsFun> tail_3(int empid,String tatext){
		List<PerPmsYG> list = fs.findEmpid(empid).getPerPmsYGs();
		List<PerPmsFun> list_1 = new ArrayList<>();
		for(PerPmsYG ppyg : list) {
			if(ppyg.getPerPmsFun().getPerPmsPe().getPesname().equals(tatext)) {
				if(ppyg.getYgwht().equals("true")) {
					PerPmsFun ppf = ppyg.getPerPmsFun();
					PerPmsFun ppf1 = new PerPmsFun();
					ppf1.setFungad(ppf.getFungad());
					ppf1.setFunid(ppf.getFunid());
					ppf1.setFunname(ppf.getFunname());
					ppf1.setFunurl(ppf.getFunurl());
					list_1.add(ppf1);
				}
			}
		}
		return list_1;
	}
}
